<template>
  <div>
    <h3>展示页面</h3>
    <!-- <p>欢迎{{ $store.state.user.username }}</p> -->
   <p>当前用户的id为 {{ obj }}</p>
    {{ name_list }}
    <table style="width:1000px;margin:0 auto">
        <tr>
            <th>编号</th>
            <th>昵称</th>
            <th>图片</th>
            <th>所属用户id</th>
        </tr>
        <tr v-for="(item,i) in name_list" :key="i">
            <td>{{ item.id }}</td>
            <td>{{ item.username }}</td>
            <td>  
                <router-link :to="{name:'Massage',params:{id:item.id}}">
                    <img :src="item.title" alt="" width="200px">
                </router-link>
               
            
            </td>
            <td>
                {{ item.user }}
            </td>
        </tr>
    </table>
  </div>
</template>

<script>
import axios from "axios"
export default {
    data(){
        return{
            obj:this.$route.params.u_id,
            name_list:[],
        }
    },
    mounted(){
        this.getname()
    },
    methods:{
        getname(){
            axios.get('http://127.0.0.1:8000/users/name/'+this.obj+'/')
            .then(resp=>{
                console.log(resp);
                this.name_list=resp.data
            })
            .catch(err=>{
                console.log(er);
            })
            
        }
    }
}
</script>

<style>

</style>